package com.buaa.xxx0321_1;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/3/25.
 */
public class SongActivity extends ListActivity {

    private List<Map<String,Object>> data;
    private void init() {
        data = new ArrayList<Map<String, Object>>();
        Map<String,Object> mp1 = new HashMap<String,Object>();
        Map<String,Object> mp2 = new HashMap<String,Object>();
        Map<String,Object> mp3 = new HashMap<String,Object>();

        mp1.put("show",R.drawable.s1);
        mp1.put("title","宋老公一号");
        mp1.put("content","老公笑起来就是帅~~~~");

        mp2.put("show",R.drawable.s2);
        mp2.put("title","宋老公二号");
        mp2.put("content","宋老公看书的样子也是很帅很帅的~(* ￣3)(ε￣ *)");

        mp3.put("show",R.drawable.s3);
        mp3.put("title","宋老公三号");
        mp3.put("content", "表白啊混蛋~~~谁会拒绝呢！");

        data.add(mp1);
        data.add(mp2);
        data.add(mp3);


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        SimpleAdapter adapter = new SimpleAdapter(this,data,R.layout.song_layout,
                new String[]{"show","title","content"},new int[]{R.id.show,R.id.title,R.id.content});
        setListAdapter(adapter);
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        Log.i("xxx",data.get(position).get("title").toString()+ data.get(position).get("content").toString());
    }
}
